package factoryfunction.controller;

import factoryfunction.service.factory.AwardFactory;
import factoryfunction.service.factory.impl.AiQiYiFactory;
import factoryfunction.service.factory.impl.DiscountFactory;
import factoryfunction.service.factory.impl.SmallGiftFactory;
import simplefactory.service.AwardInterface;
import simplefactory.vo.AwardInput;
import simplefactory.vo.Result;

/**
 * @Author liangbaigao
 * @Date 2023/9/25 23:49
 */
public class Client3 {

    public Result sendAward(AwardInput input){
        // 拿工厂实例
        AwardFactory factory = null;
        //  1 打折券 ,2 爱奇艺会员,3 小礼品
        if(input.getType().equals("1")){
            factory = new DiscountFactory();
        }
        if(input.getType().equals("2")){
            factory = new AiQiYiFactory();
        }
        if(input.getType().equals("3")){
            factory = new SmallGiftFactory();
        }
        // 通过工厂拿到实例
        AwardInterface instance = factory.getInstance();
        // 发奖
        return instance.sendAward();
    }
}
